package com.example.demo.controller;

import com.example.demo.config.Constants;
import com.example.demo.entity.vo.ResponseVO;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class AdvicesController {

    @ExceptionHandler(RuntimeException.class)
    public ResponseVO getException(RuntimeException E){
        ResponseVO responseVO = new ResponseVO();
        responseVO.setCode(Constants.EXCEPTION_CODE);
        responseVO.setInfo(E.getMessage());
        responseVO.setStatus(Constants.EXCEPTION_STATUS);
        responseVO.setData(null);
        return responseVO;
    }
}
